package top.dprkshow.practice.graph;

/**
 * @author Kent HAN
 * @date 2021/9/15
 */
public class Edge implements Comparable<Edge> {

    int v, w, weight;

    public Edge(int v, int w, int weight) {
        this.v = v;
        this.w = w;
        this.weight = weight;
    }

    public int either() {
        return v;
    }

    public int other(int vertex) {
        if (vertex == v) {
            return w;
        } else {
            return v;
        }
    }

    @Override
    public int compareTo(Edge that) {
        if (this.weight < that.weight) {
            return -1;
        } else if (this.weight > that.weight) {
            return +1;
        } else {
            return 0;
        }
    }
}
